import Mock from 'mockjs'

Mock.mock('/api/login', 'post', function(options) {
  const { username, password } = JSON.parse(options.body)
  if (username === 'root' && password === '22111105') {
    return Mock.mock({
      code: 200,
      data: {
        token: '@guid',
        username: 'Admin'
      }
    })
  }
  return { code: 401, message: 'Invalid credentials' }
})